package com.goldmantis.alitrip.controller.authorization;

import com.goldmantis.alitrip.common.ReturnMessage;
import com.goldmantis.alitrip.common.annotation.Log;
import com.goldmantis.alitrip.common.mongodb.MongoService;
import com.goldmantis.alitrip.common.sysenum.EnumLogCatagory;
import com.goldmantis.alitrip.common.sysenum.EnumOperationType;
import com.goldmantis.alitrip.mapper.SysUserResMapper;
import com.goldmantis.alitrip.service.SysUserResService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:Shmily
 * @Description:
 * @Date:Create in 15:21 2018/3/8
 */
@RestController
@Api(description = "用户权限获取")
@RequestMapping("sys/user/res")
@RequiresAuthentication
public class SysUserResController {

    @Autowired
    private SysUserResService sysUserResService;

    @Autowired
    private MongoService mongoService;

    @GetMapping()
    @ApiOperation(value = "根据用户Id，系统Id获取菜单信息", httpMethod = "GET")
    @Log(operationName = "根据用户Id，系统Id获取菜单信息", logCatagory = EnumLogCatagory.access, operationType = EnumOperationType.query)
    public ResponseEntity<ReturnMessage> getResBySystemIdAndUserId(
            @ApiParam(value = "用户Id", required = true) @RequestParam Long userId) {
        return ResponseEntity.ok(ReturnMessage.success(sysUserResService.getResBySystemIdAndUserId(userId)));
    }
}
